package com.shitou.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.shitou.dao.MileStoneDao;
import com.shitou.pojo.Milestone;
import com.shitou.pojo.Project;
import com.shitou.pojo.User;
import com.shitou.util.DateUtil;

@Service
@Transactional
public class MilestoneService {

	@Resource
	private MileStoneDao dao;
	@Resource
	private NewsService newsService;
	
	public void save(Milestone milestone) {
		dao.save(milestone);
	}
	
	public int save(Milestone milestone, Project project, User user) {
		milestone.setCreatedate(DateUtil.getNow());
		milestone.setProject(project);
		dao.save(milestone);
		newsService.save(milestone, user);
		return milestone.getId();
	}
	
	public Milestone findById(int id) {
		return dao.findById(id);
	}
}
